import React from 'react';
import styles from '@/assets/css/login.module.css';
const Login = () => {
    const [form] = React.UI.Form.useForm()
    const LoginFinish = async (values: any) => 
    {
        let result = await React.HTTP.post('/business/UserLogin', values)
        if (result.code == 0) 
        {
            React.error(result.msg)
            return false
        }

        React.success(result.msg, () => {
            //保存用户信息
            React.Cookie.save('business', result.data)
            window.location.href = '/business/index'
            // navigate('/business/index')
        })
    }
    return (
        <>
            <div className={styles.headers}>
                <div className={styles.userinfo}>
                    <div className={styles.avatar}></div>
                </div>
                <div className={styles.corrugated}>
                    <div className={`${styles.wave_top} ${styles.wave_item}`}></div>
                    <div className={`${styles.wave_middle} ${styles.wave_item}`}></div>
                </div>
            </div>
            <div className={styles.login}>
                <React.UI.Form
                    layout='horizontal'
                    mode='card'
                    form={form}
                    onFinish={LoginFinish}
                    initialValues={{
                        mobile: '18888888888',
                        password: 'root'
                    }}
                    footer={
                        <div style={{ margin: '16px 16px 0' }}>
                            <React.UI.Button shape='rounded' type='submit' color='warning' block>
                                登陆注册
                            </React.UI.Button>
                        </div>
                    }
                >
                    <React.UI.Form.Item
                        rules={[{ required: true, message: '请填写手机号码' }, { pattern: /^1[356789]\d{9}$/, message: '请输入正确的手机号码' }]}
                        name='mobile'
                        label='手机号码'
                    >
                        <React.UI.Input placeholder='请输入手机号码' />
                    </React.UI.Form.Item>

                    <React.UI.Form.Item
                        rules={[{ required: true, message: '请填写密码' }]}
                        name='password'
                        label='密码'
                    >
                        <React.UI.Input placeholder='请输入密码' type='password' />
                    </React.UI.Form.Item>

                </React.UI.Form>

                <div className={styles.tips}>
                    <React.Router.NavLink to="/" >
                        首页
                    </React.Router.NavLink>
                </div>
            </div>
        </>
    )
};

export default Login;